package utils

import (
	"log"

	"gopkg.in/ini.v1"
)

var (
	RunMode  string
	HttpPort string
	JwtKey   string
	Url      string
	Show_sql bool
)

func init() {
	file, err := ini.Load("config/config.ini")
	if err != nil {
		log.Fatal("配置文件读取错误，请检查文件路径:", err)
	}

	LoadData(file)
}

// func LoadServer(file *ini.File) {
// 	AppMode = file.Section("server").Key("AppMode").MustString("debug")
// 	HttpPort = file.Section("server").Key("HttpPort").MustString(":3000")
// 	JwtKey = file.Section("server").Key("JwtKey").MustString("89js82js72")
// }

func LoadData(file *ini.File) {
	RunMode = file.Section("app").Key("RunMode").MustString("debug")
	HttpPort = file.Section("app").Key("DbPort").MustString(":8000")
	Url = file.Section("mysql").Key("Url").String()
	Show_sql, _ = file.Section("mysql").Key("Show_sql").Bool()

}
